#include <iostream>
#define YUILogComponent "YJUI"
#include "YUILog.h"
#include "YCommandLine.h"

#include "YJUI.h"

/** INIT OF STATIC CALLBACKS for registering java - C++ class **/
constructor_callback YJUI::create_widget_factory_cb=NULL;
constructor_callback YJUI::create_optional_widget_factory_cb=NULL;
constructor_callback YJUI::create_application_cb=NULL;
top_constructor_callback YJUI::constructor_cb=NULL;



int YJUI::test(){		/***
 * JUI.h
 **/
	YJUI *ui = createUI(false);
	YJWidgetFactory * factory = ui->createWidgetFactory();
	YJOptionalWidgetFactory * oFactory = ui->createOptionalWidgetFactory();
	YJApplication * app = ui->createApplication();

	YJDialog *dialog = factory->createDialog(YMainDialog,YDialogNormalColor);
	dialog->test();

//	YJLabel *label = factory->createLabel(NULL, false,false);
//	label->test();

	return 0;
}

YJUI::YJUI(int id, bool with_threads) :
	YUI(with_threads) {
	classId = id;
	std::cout << "new YJUI created with ID: "<< classId << std::endl;
	yuiMilestone() << "YJUI was created from constructor" << endl;
	topmostConstructorHasFinished();
}

YJUI * YJUI::createUI(bool withThreads) {

	std::cout << "createUI called" << std::endl;
	yuiMilestone() << "YJUI was created" << endl;
	static YJUI *ui = 0;
	if (!ui) {
		YCommandLine cmdLine;
		ui = new YJUI(constructor_cb(), withThreads);
	}
	return ui;
}

YJWidgetFactory * YJUI::createWidgetFactory() {
	std::cout << "createWidgetFactory called" << std::endl;
	yuiMilestone() << "" << endl;
	int wfId = create_widget_factory_cb(classId);
	return new YJWidgetFactory(wfId);
}
YJOptionalWidgetFactory* YJUI::createOptionalWidgetFactory() {
	std::cout << "createOptionalWidgetFactory called" << std::endl;
	int owfId = create_optional_widget_factory_cb(classId);
	return new YJOptionalWidgetFactory(owfId);
}
YJApplication * YJUI::createApplication() {
	int aId = create_application_cb(classId);
	return new YJApplication(aId);
}
YEvent* YJUI::runPkgSelection(YWidget* widget) {
	return new YEvent();
}
void YJUI::idleLoop(int i) {
	return;
}


